package com.ccrfid.rmc6.repository.personnel;

import com.ccrfid.rmc6.entity.personnel.PersonnelView;
import com.ccrfid.rmc6.repository.search.SearchableRepository;
import org.springframework.data.repository.Repository;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.List;
import java.util.Set;

public interface PersonnelViewRepository extends Repository<PersonnelView, Long>, SearchableRepository<PersonnelView> {
    //
    PersonnelView getById(Long id);
    //
    PersonnelView getByCardNumber(Long cardNumber);
    //
    List<PersonnelView> getAllByLocatorAddressIsNotNull();
    List<PersonnelView> getAllByLocatorAddress(Integer locatorAddress);
    //
    List<PersonnelView> getAllByOrgId(Long orgId);

    List<PersonnelView> getAllByOrgIdAndEnabledAndIdNotIn(Long orgId, Integer enabled, List<Long> idList);

    List<PersonnelView> getAllByOrgIdAndEnabled(Long orgId, Integer enabled);

    List<PersonnelView> getAllByIdIn(List<Long> idList);

    List<PersonnelView> getAllByIdIn(Set<Long> idSet);

    List<PersonnelView> getTop5ByPersonnelNameContainingOrderByPersonnelName(String personnelName);
    List<PersonnelView> getTop10ByPersonnelNameContainingOrderByPersonnelName(String personnelName);
    List<PersonnelView> getTop5ByNameAcronymStartingWithOrderByNameAcronym(String nameAcronym);
    List<PersonnelView> getTop10ByNameAcronymStartingWithOrderByNameAcronym(String nameAcronym);
    List<PersonnelView> getByPersonnelSn(String personnelSn);
    List<PersonnelView> getByIdNumber(String idNumber);
    List<PersonnelView> getTop5ByPhoneNumber(String phoneNumber);
    List<PersonnelView> getTop10ByPhoneNumber(String phoneNumber);

    List<PersonnelView> getTop5ByPersonnelNameContainingAndEnabledOrderByPersonnelName(String personnelName, Integer enabled);
    List<PersonnelView> getTop10ByPersonnelNameContainingAndEnabledOrderByPersonnelName(String personnelName, Integer enabled);
    List<PersonnelView> getTop5ByNameAcronymStartingWithAndEnabledOrderByNameAcronym(String nameAcronym, Integer enabled);
    List<PersonnelView> getTop10ByNameAcronymStartingWithAndEnabledOrderByNameAcronym(String nameAcronym, Integer enabled);
    List<PersonnelView> getByPersonnelSnAndEnabled(String personnelSn, Integer enabled);
    List<PersonnelView> getByIdNumberAndEnabled(String idNumber, Integer enabled);
    List<PersonnelView> getTop5ByPhoneNumberAndEnabled(String phoneNumber, Integer enabled);
    List<PersonnelView> getTop10ByPhoneNumberAndEnabled(String phoneNumber, Integer enabled);

    Boolean existsById(Long id);

    Long countByEnabledAndPersonnelType(Integer enabled, Integer personnelType);
    Long countByEnabledAndPersonnelTypeAndOnlineStatus(Integer enabled, Integer personnelType, Integer onlineStatus);

    List<PersonnelView> getAllByEnabledAndPersonnelTypeIn(Integer enabled, List<Integer> typeList);
    //
    List<PersonnelView> getAllByEnabledAndPersonnelType(Integer enabled, Integer personnelType);

    List<PersonnelView> getAllByEnabled(Integer enabled);

    int countAllByPersonnelTypeInAndEnabled(List<Integer> personnelTypes, Integer enabled);

    int countAllByPersonnelTypeInAndEnabledAndOnlineStatus(List<Integer> personnelTypes, Integer enabled, Integer onlineStatu);

    int countAllByEnabledAndOrgIdIn(Integer enable, List<Long> orgIdList);

    int countAllByEnabledAndOrgIdInAndOnlineStatus(Integer enable, List<Long> orgIdList, Integer onlineStatus);

    int countAllByEnabledAndPosIsNotNullAndOrgIdInAndOnlineStatus(Integer enabled, List<Long> orgIdList, Integer onlineStatus);

    int countAllByEnabledAndPersonnelTypeAndPosIsNotNullAndOrgIdIn(Integer enabled,Integer personnelType, List<Long> orgIdList);

    PersonnelView getByHexNumber(String hexNumber);
}
